/**
 * System User
 */
class User {
	String userName
	String password
	String firstName
	String department
	Calendar creationTime = Calendar.getInstance()
	int maxAnswers = 1

	static mapping = {
		table 'GEXT_USER'
		roles joinTable:'GEXT_USER_ROLE'
	}

	static hasMany = [roles: Role]

	static constraints = {
		userName(unique:true, blank:false, size:2..16)
		password(blank:false, size:6..16)
		firstName(blank:false, maxSize:16)
		department(blank:false, maxSize:32)
	}

	static optionals = {
		["maxAnswers"]
	}

	String toString() {
		"${this.firstName}"
	}
}
